package com.haohan.stock.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.haohan.stock.service.StockService;
import com.haohan.stock.vo.ReturnType;

@RestController
@RequestMapping(value = "/stock")
public class StockController {
	
	@Autowired
	private StockService stockService;
	
	/**
	 * 初始化股票数据
	 */
	@RequestMapping(value="/saveinit",method =RequestMethod.GET)
	public ResponseEntity<ReturnType<String>> save() throws Exception {
		ReturnType<String> basedocReturnType = new ReturnType<String>();
		basedocReturnType.setFlag(0);
		basedocReturnType.setDesc("");
		basedocReturnType.setData(stockService.saveinit());
		return new ResponseEntity<ReturnType<String>>(basedocReturnType,HttpStatus.OK);
	}
	
	@RequestMapping(value="/saveinit8",method =RequestMethod.GET)
	public ResponseEntity<ReturnType<String>> save8() throws Exception {
		ReturnType<String> basedocReturnType = new ReturnType<String>();
		basedocReturnType.setFlag(0);
		basedocReturnType.setDesc("");
		basedocReturnType.setData(stockService.saveinit8());
		return new ResponseEntity<ReturnType<String>>(basedocReturnType,HttpStatus.OK);
	}
	
	@RequestMapping(value="/calcea",method =RequestMethod.GET)
	public ResponseEntity<ReturnType<String>> calcea() throws Exception {
		ReturnType<String> basedocReturnType = new ReturnType<String>();
		basedocReturnType.setFlag(0);
		basedocReturnType.setDesc("");
		basedocReturnType.setData(stockService.calcea());
		return new ResponseEntity<ReturnType<String>>(basedocReturnType,HttpStatus.OK);
	}

	
}